]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionPrefs: Skip main window when launched with a UUID
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 26 May 2014 23:36:41 +0000 (01:36 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 27 May 2014 16:02:25 +0000 (18:02 +0200)
The extension-prefs tool is used by gnome-tweak-tool and the
extensions web site to display preferences. However as those
already implement their own extension lists, the main window
is not useful in that context (to not say it is rather silly).

Just skip the main window and only show the specified extension's
preference dialog in those cases.

https://bugzilla.gnome.org/show_bug.cgi?id=730829

js/extensionPrefs/main.js

index 3c86498f67ee580f64fbd1ece29f8d45ccdfd203..e77ac66ff04da4def440b5603642a570a2896821 100644 (file)
@@ -52,6 +52,8 @@ const Application = new Lang.Class({
         this._extensionPrefsModules = {};
 
         this._startupUuid = null;
+        this._loaded = false;
+        this._skipMainWindow = false;
     },
 
     _extensionAvailable: function(uuid) {
@@ -100,8 +102,18 @@ const Application = new Lang.Class({
 
         let dialog = new Gtk.Dialog({ use_header_bar: true,
                                       modal: true,
-                                      title: extension.metadata.name,
-                                      transient_for: this._window });
+                                      title: extension.metadata.name });
+
+        if (this._skipMainWindow) {
+            this.application.add_window(dialog);
+            if (this._window)
+                this._window.destroy();
+            this._window = dialog;
+            this._window.window_position = Gtk.WindowPosition.CENTER;
+        } else {
+            dialog.transient_for = this._window;
+        }
+
         dialog.set_default_size(600, 400);
         dialog.get_content_area().add(widget);
         dialog.show();
@@ -220,6 +232,8 @@ const Application = new Lang.Class({
         if (this._startupUuid && this._extensionAvailable(this._startupUuid))
             this._selectExtension(this._startupUuid);
         this._startupUuid = null;
+        this._skipMainWindow = false;
+        this._loaded = true;
     },
 
     _onActivate: function() {
@@ -235,16 +249,21 @@ const Application = new Lang.Class({
     _onCommandLine: function(app, commandLine) {
         app.activate();
         let args = commandLine.get_arguments();
+
         if (args.length) {
             let uuid = args[0];
 
+            this._skipMainWindow = true;
+
             // Strip off "extension:///" prefix which fakes a URI, if it exists
             uuid = stripPrefix(uuid, "extension:///");
 
             if (this._extensionAvailable(uuid))
                 this._selectExtension(uuid);
-            else
+            else if (!this._loaded)
                 this._startupUuid = uuid;
+            else
+                this._skipMainWindow = false;
         }
         return 0;
     }